package com.jing.weibo.service.ranking;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.jing.system.model.PageCls;
import com.jing.weibo.mapper.ranking.UserCommentMapper;
import com.jing.weibo.pojo.ranking.UserComment;
import com.jing.weibo.pojo.ranking.UserCommentFans;

/**
 * 榜上有名[用户微博的评论]的Service
 * @author jing.yue
 * @version 2012/10/18 1.0.0
 */
@Component
public class UserCommentService {

	@Autowired
	private UserCommentMapper userCommentMapper;

	/**
	 * 保存用户微博评论信息
	 * @param userComment
	 * @throws Exception
	 */
	public void saveUserComment(UserComment userComment) throws Exception {
		userCommentMapper.saveUserComment(userComment);
	}

	/**
	 * 查询用户评论[根据用户名/类型/评论ID]
	 * @param userComment
	 * @return
	 * @throws Exception
	 */
	public UserComment findByUserComment(UserComment userComment) throws Exception {
		return userCommentMapper.findByUserComment(userComment);
	}

	/**
	 * 分页查询@或评论的粉丝信息
	 * @param userComment
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findByAtOrCommentUserComment(UserComment userComment) throws Exception {
		List<UserCommentFans> userComments = userCommentMapper.findStatisUserCommentFans(userComment);
		Integer countSize = userCommentMapper.findStatisUserCommentFansCount(userComment);
		PageCls pageCls = PageCls.setPageCls(userComment.getPage(), userComment.getSize(), null, null, countSize, userComments.size(), userComments);
		return pageCls.getPageInfo();
	}
}
